<script>
    $(function() {
        var set=1;
        var unset=0;
        jQuery( function() {
            $( '.checkall' ).live('click', function() {
                $( '.chbx-element' ).each(function () {
                    if(set==1){ $( '.chbx-element' ).attr('checked', true); unset=0; }
                    if(set==0){ $( '.chbx-element' ).attr('checked', false); unset=1; }
                });
                set=unset;
            });
            $( '.deleteall' ).live('click', function() {
                $( '.chbx-element' ).each(function () {
                    $( '.chbx-element' ).attr('checked', true);
                });
            });
        });
    });
</script>
<?php echo$this->abc ?>
<div id="confirm-form" title="Delete these projects?"></div>
<div class="box">
    <h4 class="white">Project list</h4>
    <div class="box-container">
        <form action="" method="post" id="del-project">
            <table class="table-long">
                <thead>
                    <tr>
                        <td></td>
                        <td>Project</td>
                        <td>Code</td>
                        <td>SVN</td>
                        <?php if ($this->role=='admin')
                        echo '<td>Actions</td>' ?>
                    </tr>
                </thead>
                <?php
                if ($this->role == 'admin') :
                ?>
                <tfoot>
                    <tr>
                        <td class="col-chk"><input type="checkbox" /></td>
                        <td colspan="4"><div class="align-right">
                                <select name="deleteoption" class="form-select">
                                    <option value="optional">Bulk Options</option>
                                    <option value="deleteall" class="deleteall">Delete All</option>
                                </select>
                                <a href="#" class="button del-project"><span>perform action</span></a></div>
                        </td>
                    </tr>
                </tfoot>
                <?php endif;?>
                <tbody>
                    <?php
                    if (isset($this->projects)) :
                        foreach ($this->projects as $i => $project) :
                            ?>
                            <tr<?php echo (($i + 1) % 2) ? "class='odd'" : "" ?>>
                                <td class="col-chk"><input name ="projects[]" value ="<?php echo $project->id ?>"  class="chbx-element" type="checkbox" /></td>
                                <td class="col-second row-nav"><a href="/project/detail/<?php echo $project->id ?>">  <?php echo$project->name; ?></a></td>
                                <td class="col-first"><?php echo $project->code ?></td>
                                <td class="col-second row-nav"><?php echo $project->svn_url ?></td>
                                <td class="row-nav">
                                    <?php if ($this->role == 'admin') : ?>
                                        <a href="/project/edit/<?php echo $project->id ?>" class="table-edit-link">Edit</a> <span class="hidden"> | </span> <a href="/project/delete/<?php echo $project->id ?>" class="table-delete-link"><div id="delete-user">Delete</div></a>
                                    <?php
                                    endif;
                                    //} else if ($isProjectOwner) {
//                                        foreach ($projectOwner as $p) {
//                                            if ($p == $project->id) {
                                    ?>
        <!--                                                <a href="/project/edit/<?php echo $project->id ?>" class="table-edit-link">Edit</a>-->
                                    <?php
//                                            }
//                                        }
//                                    }
                                    ?>
                                </td>
                            </tr>
                            <?php
                        endforeach;
                    endif;
                    ?>
                </tbody>
            </table>  
        </form>
    </div><!-- end of div.box-container -->
</div> <!-- end of div.box -->